package com.java.example.util

import android.graphics.Color
import android.os.CountDownTimer
import android.widget.TextView

class MyCountDownTimer(millisInFuture: Long, countDownInterval: Long, private val mView: TextView) : CountDownTimer(millisInFuture, countDownInterval) {
    //计时过程
    override fun onTick(l: Long) {
        //防止计时过程中重复点击
        mView.isClickable = false
        mView.text = (l / 1000).toString() + "s"
        //        mView.setTextColor(ContextCompat.getColor(Latte.getApplicationContext(), R.color.text_gray));
        mView.setTextColor(Color.WHITE)
    }

    //计时完毕的方法
    override fun onFinish() {
        //重新给Button设置文字
        mView.text = "重新获取"
        //设置可点击
        mView.isClickable = true
        mView.setTextColor(Color.WHITE)
    }
}
